package com.zjdt.project.mysystem.controller;

import java.util.Date;
import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.zjdt.project.mysystem.domain.Swipper;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.zjdt.framework.aspectj.lang.annotation.Log;
import com.zjdt.framework.aspectj.lang.enums.BusinessType;
import com.zjdt.project.mysystem.domain.FlushScreen;
import com.zjdt.project.mysystem.service.IFlushScreenService;
import com.zjdt.framework.web.controller.BaseController;
import com.zjdt.framework.web.domain.AjaxResult;
import com.zjdt.common.utils.poi.ExcelUtil;
import com.zjdt.framework.web.page.TableDataInfo;

/**
 * 闪屏图片Controller
 * 
 * @author dusin
 * @date 2024-07-26
 */
@RestController
@RequestMapping("/mysystem/flush")
public class FlushScreenController extends BaseController
{
    @Autowired
    private IFlushScreenService flushScreenService;

    /**
     * 查询闪屏图片列表
     */
    @PreAuthorize("@ss.hasPermi('mysystem:flush:list')")
    @GetMapping("/list")
    public TableDataInfo list(FlushScreen flushScreen)
    {
        startPage();
        List<FlushScreen> list = flushScreenService.selectFlushScreenList(flushScreen);
        return getDataTable(list);
    }

    /**
     * 导出闪屏图片列表
     */
    @PreAuthorize("@ss.hasPermi('mysystem:flush:export')")
    @Log(title = "闪屏图片", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, FlushScreen flushScreen)
    {
        List<FlushScreen> list = flushScreenService.selectFlushScreenList(flushScreen);
        ExcelUtil<FlushScreen> util = new ExcelUtil<FlushScreen>(FlushScreen.class);
        util.exportExcel(response, list, "闪屏图片数据");
    }

    /**
     * 获取闪屏图片详细信息
     */
    @PreAuthorize("@ss.hasPermi('mysystem:flush:query')")
    @GetMapping(value = "/{flushScreenId}")
    public AjaxResult getInfo(@PathVariable("flushScreenId") Long flushScreenId)
    {
        return success(flushScreenService.selectFlushScreenByFlushScreenId(flushScreenId));
    }

    /**
     * 新增闪屏图片
     */
    @PreAuthorize("@ss.hasPermi('mysystem:flush:add')")
    @Log(title = "闪屏图片", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FlushScreen flushScreen)
    {
        flushScreen.setCreateBy(getUsername());
        flushScreen.setCreateTime(new Date());
        flushScreen.setUpdateBy(getUsername());
        flushScreen.setUpdateTime(new Date());
        return toAjax(flushScreenService.insertFlushScreen(flushScreen));
    }

    /**
     * 修改闪屏图片
     */
    @PreAuthorize("@ss.hasPermi('mysystem:flush:edit')")
    @Log(title = "闪屏图片", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FlushScreen flushScreen)
    {
        flushScreen.setUpdateBy(getUsername());
        flushScreen.setUpdateTime(new Date());
        return toAjax(flushScreenService.updateFlushScreen(flushScreen));
    }

    /**
     * 状态修改
     */
    @PreAuthorize("@ss.hasPermi('system:flush:edit')")
    @Log(title = "轮播图片", businessType = BusinessType.UPDATE)
    @PutMapping("/changeStatus")
    public AjaxResult changeStatus(@RequestBody FlushScreen flush)
    {
        flush.setUpdateBy(getUsername());
        flush.setUpdateTime(new Date());
        return toAjax(flushScreenService.updateStatus(flush));
    }

    /**
     * 删除闪屏图片
     */
    @PreAuthorize("@ss.hasPermi('mysystem:flush:remove')")
    @Log(title = "闪屏图片", businessType = BusinessType.DELETE)
	@DeleteMapping("/{flushScreenIds}")
    public AjaxResult remove(@PathVariable Long[] flushScreenIds)
    {
        return toAjax(flushScreenService.deleteFlushScreenByFlushScreenIds(flushScreenIds));
    }
}
